<%--
  Created by IntelliJ IDEA.
  User: yujiajing
  Date: 2022/10/14
  Time: 9:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="com.cn.Mapper.userMapper.UserMapper" %>
<%@ page import="com.cn.util.SqlsesstionUtil" %>
<%@ page import="com.cn.entity.user.User" %>
<%@ page import="java.util.List" %>
<%@ page import="com.cn.Mapper.enployeeMapper.EmployeeMapper" %>
<%@ page import="com.cn.entity.enployee.Employee" %>
<%@ page import="com.cn.Mapper.goodsMapper.GoodsMapper" %>
<%@ page import="com.cn.entity.goods.Goods" %><%--
  Created by IntelliJ IDEA.
  User: yujiajing
  Date: 2022/10/3
  Time: 14:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
  <title>Title</title>
  <%--  引入jQuery包  --%>
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.js"></script>

  <!-- 引入layui css -->
  <link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui-v2.5.6/css/layui.css" />

  <!-- 引入layui js -->
  <script src="https://www.layuicdn.com/layui-v2.5.6/layui.js"></script>

</head>

<body>

<script>
  function ConfirmDelete(id){
    if(confirm("确认删除数据？")){
      OperatorUser(id);

    }
  }

  function OperatorUser(id) {

    $.ajax({

      type : "post",

      url : "employee/delete",

      dateType : "String",

      data : {

        id : id

      },

      success : function(data) {
        alert("删除成功");
        $("#tr_"+id).remove();


      },

      error : function() {
        alert("失败");

        $("#tr_"+id).remove();

      }

    });

  }
</script>

<%
  SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
 GoodsMapper goodsMapper =sqlSession.getMapper(GoodsMapper.class);
  List<Goods> goodsList = goodsMapper.showAll();
%>
<table id="UserTable" class="layui-table"  >

  <tr>
    <td>商品编号</td>
    <td>商品名称</td>
    <td>商品价格</td>
    <td >商品类别编号</td>
    <td>商品制造厂家</td>
      <td>进货日期</td>
    <td>操作</td>
  </tr>

  <%for (Goods goods:goodsList){%>
  <%--  --%>
  <tr id="tr_<%=goods.getGoods_id()%>">
    <%--    --%>
     <td><%=goods.getGoods_id()%></td>
      <td><%=goods.getGoods_name()%></td>
      <td><%=goods.getGoods_price()%></td>
      <td><%=goods.getGoods_sortId()%></td>
      <td><%=goods.getGoods_manufacture()%></td>
        <td><%=goods.getGoods_productDate()%></td>


    <td>
      <%--            <a class="layui-btn layui-btn-xs" lay-event="edit" href="UpdateUser.jsp?id=<%=user.getId()%>&username=<%=user.getUsername()%>&password=<%=user.getPassword()%>">编辑</a>--%>
      <a class="layui-btn layui-btn-danger layui-btn-xs"  href="javascript:void(0);"id="del_<%=goods.getGoods_id()%>"  onclick="ConfirmDelete(<%=goods.getGoods_id()%>)">下架</a>
    </td>
    <%}%>
  </tr >
</table>
<a href="InsertUser.jsp?">上架新品</a>
</body>
</html>


